const { expect } = require('chai');
const { ethers } = require('hardhat');

describe('Tokenize', () => {
    let owner, sender, recipient, inspector
    let token

    beforeEach(async () => {
        // Setup accounts
        [owner, sender, recipient] = await ethers.getSigners()
        
        const Token = await ethers.getContractFactory('Token')
        token = await Token.deploy(
            'DigitalCoin',
            'OT'
            )

        console.log(token.address)
        console.log()
        // Mint 
        let transaction = await token.connect(owner).mintToken(owner.address, 100)
        await transaction.wait()
        let transaction1 = await token.connect(sender).mintToken(sender.address, 100)
        await transaction1.wait()
        let transfer = await token.connect(sender).transferFrom(sender.address, recipient.address, 100)
        await transfer.wait()


    })

    describe('Deployment', () => {
        it('Returns total supply', async () => {
            const result = await token.connect(owner).getTotalSupply()
            expect(result).to.be.equal(1000000000000000200n)
        })

        it('Returns token name', async () => {
            const result = await token.connect(owner).getName()
            expect(result).to.be.equal('DigitalCoin')
        })
        
        it('Returns token symbol', async () => {
            const result = await token.connect(owner).getSymbol()
            expect(result).to.be.equal('OT')
        })
    })

    describe('transfer', () => {
        
        it('Returns balance of', async () => {
            const result = await token.connect(recipient).balanceOf(recipient.address)
            expect(result).to.be.equal(100)
        })
    })

})